script_enemy_main{

let shot1=0;
let bullet1=[];
let timer1=[];

let character="Hotaru";
let cutin=character;
let dispelled=0;
let spellcards=5;
let spellcardnumber=20;
let damagerate=10;
let outfit=6;
outfit=(128*outfit)-128;
let usespell=0;
let bgfade=0;
let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEfire1=("\script\SoundEffects\fire1.wav");
let SEshotm3=("\script\SoundEffects\shotm3.wav");

let BG1=("\script\Images\BackgroundLayers\Hotaru1.png");
let BG2=("\script\Images\BackgroundLayers\Hotaru2.png");
let GRboss=("\script\Images\CharacterSprites\Hotaru.png");

#include_function "script/Functions/SetSpellcardCommonData.txt";
#include_function "script/Functions/SpellcardNameLoad.txt";
#include_function "script/Functions/HealthBarLoad.txt";
#include_function "script/Functions/CutInLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsHotaru1.txt");

	LoadSE("\script\SoundEffects\fire1.wav");
	LoadSE("\script\SoundEffects\shotm3.wav");
	LoadSE("\script\SoundEffects\magics5.wav");

	LoadGraphic("\script\Images\BackgroundLayers\Hotaru1.png");
	LoadGraphic("\script\Images\BackgroundLayers\Hotaru2.png");
	LoadGraphic("\script\Images\CharacterSprites\Hotaru.png");

	SetScore(500000);
	SetLife(400);
	SetTimer(50);
	SetInvincibility(120);
	SetDamageRate(10,10);
	SetEnemyMarker(true);
	MagicCircle(true);
	#include_function "script/Functions/Focus.txt";
	Focus(character);
	SetEffectForZeroLife(60,100,1);
	SetMovePosition02(cx,cy,50);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(100,100,100,100);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=6; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

let difficulty="";
if(GetCommonDataDefault("Difficulty",2)==1){ difficulty="Easy"; }
if(GetCommonDataDefault("Difficulty",2)==2){ difficulty="Normal"; }
if(GetCommonDataDefault("Difficulty",2)==3){ difficulty="Hard"; }
if(GetCommonDataDefault("Difficulty",2)==4){ difficulty="Lunatic"; }

SpellcardName("Hyperthermia [Heatwave] ("~difficulty~")",spellcardnumber);
HealthBar();
Portrait(cutin,1);


if(time%210==0 && time>=60){
	if(GetPlayerX>minx+50 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),cy,1.5);
	}
	if(GetPlayerX<=minx+100){
	SetMovePosition01(GetPlayerX+rand(15,30),cy,1.5);
	}
	if(GetPlayerX>=maxx-100){
	SetMovePosition01(GetPlayerX-rand(15,30),cy,1.5);
	}
}


if(frame==210){
let angle=rand(0,360);
	loop(200){
	shot1=(Obj_Create(OBJ_SHOT));
	Obj_SetPosition(shot1,GetX,GetY);
	Obj_SetAngle(shot1,angle);
	Obj_SetSpeed(shot1,0.8);
	ObjShot_SetBombResist(shot1,true);
	Obj_SetAutoDelete(shot1,true);
	ObjShot_SetGraphic(shot1,27);
	bullet1=bullet1~[shot1];
	timer1=timer1~[shot1];
	timer1[length(bullet1)-1]=0;
	angle+=360/200;
	}
usespell=-30;
PlaySE(SEfire1);
}
if(frame>=350 && frame<550 && time%35==0){
let angle=-time*5.3;
	loop(5){
	let shot2=0;
	CreateShotA(shot2,GetX,GetY,20);
	SetShotDataA(shot2,0,1.2,angle,0,0,0,133);
	FireShot(shot2);
	angle+=360/5;
	}
PlaySE(SEshotm3);
}
if(frame==580){ frame=100; }


let i=0;
while(i<length(bullet1)){
	if(Obj_BeDeleted(bullet1[i])){
	bullet1=erase(bullet1,i); timer1=erase(timer1,i); i--;
	}
	else{
	if(timer1[i]==140){ ObjShot_FadeDelete(bullet1[i]); }
	timer1[i]=timer1[i]+1;
	}
i++;
}


if(time==60){
let angle=rand(0,360);
	loop(8){
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Hotaru - Heatwave - Familiar.txt",cx,cy,0,0,angle);
	angle+=360/8;
	}
}


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss2X",GetX); SetCommonData("Boss2Y",GetY);

#include_function "script/Functions/SpellcardName.txt";
#include_function "script/Functions/HealthBar.txt";
#include_function "script/Functions/CutIn.txt";
}

@BackGround{
	if(bgfade<255){ bgfade+=5; }

	SetGraphicRect(0,0+time,300,300+time);
	SetGraphicScale(2+0.3*cos(time),2-0.3*cos(time));
	SetTexture(BG1);
	SetAlpha(bgfade);
	SetColor(180,180,180);
	SetRenderState(ALPHA);
	SetGraphicAngle(0,0,0);
	DrawGraphic(cx,cy);
	
	SetGraphicRect(0-time,0-time/2,300-time,300-time/2);
	SetGraphicScale(2,2);
	SetTexture(BG2);
	DrawGraphic(cx,cy);
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }
	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}

@Finalize{
//	SetCommonData("Conversation",1);
	NewPointData(spellcardnumber,GetCommonData("Difficulty"));
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}